<template>
  <el-dialog
    :title="lookOrEdit == 1?'新增':lookOrEdit == 2?'编辑':'查看'"
    :visible.sync="dialogFormVisible"
    @close="close"
    width="80%"
    :destroy-on-close="true"
  >
    <div v-loading="loading" class="readonly">
      <el-form :model="form" :rules="rules" ref="form">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="xmmc" label="项目名称">
              <el-input
                size="medium"
                v-model.trim="form.xmmc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
              <!--  v-if="lookOrEdit" -->
              <!-- <span v-else>{{form.xmmc}}</span> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="xmbh" label="项目编号">
              <el-input
                size="medium"
                v-model.trim="form.xmbh"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              prop="xmzt"
              label="项目状态"
              :rules="[{required:true,message:'该值不能为空', trigger: 'blur'}]"
            >
              <el-select
                size="medium"
                v-model="form.xmzt"
                placeholder="请选择"
                style="width:100%"
                ref="sel1"
                :disabled="lookOrEdit == 3"
                @change="$refs.form.clearValidate('xmzt')"
              >
                <el-option
                  :label="item.keys"
                  :value="item.values"
                  v-for="item in resdata.xmzt"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">项目概况</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="lxbm" label="路线编码">
              <el-input
                size="medium"
                v-model="form.lxbm"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="lxmc" label="路线名称">
              <el-input
                size="medium"
                v-model="form.lxmc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <!-- <el-form-item prop="jszt" label="建设主体" >
              <el-select size="medium" v-model="form.jszt" placeholder="请选择" style="width:100%">
                <el-option
                  :label="item.name"
                  :value="item.id"
                  v-for="item in resdata.organize"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>-->
            <el-form-item
              prop="jszt"
              label="建设主体"
              :rules="[{required:true,message:'该值不能为空', trigger: 'blur'}]"
            >
              <!-- <el-select
                size="medium"
                v-model="form.jszt"
                class="treeSel"
                ref="sel"
                placeholder="请选择"
                style="width:100%"
                @change="$refs.form.clearValidate('jszt')"
                :disabled="lookOrEdit == 3"
                @focus="handleNodeFocus"
              >

                <el-option
                  :value="mineStatusValue"
                  :label="mineStatus"
                  class="trees"
                  ref="tree"
                  style="height:200px;"
                >

                  <el-tree
                    ref="vueTree"
                    :data="dataStructure"
                    :props="defaultProps"
                    node-key="id"
                    @node-click="handleNodeClick"
                    style="overflow-y:scroll;"
                    @node-expand="handleNodeExpand"
                    :check-on-click-node="true"
                  ></el-tree>
                </el-option>
              </el-select>-->
              <el-input
                size="medium"
                v-model.trim="form.jszt"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item prop="gcgk" label="工程概况">
              <el-input
                size="medium"
                type="textarea"
                v-model.trim="form.gcgk"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="qdzh" label="起点桩号">
              <el-input
                size="medium"
                v-model="form.qdzh"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="zdzh" label="终点桩号">
              <el-input
                size="medium"
                v-model="form.zdzh"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item 
            prop="ljkd" 
            label="路基宽度(m)"
            
            >
              <el-input
                size="medium"
                v-model="form.ljkd"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="lmdk" label="路面宽度(m)" >
              <el-input
                size="medium"
                v-model="form.lmdk"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="lmjg" label="路面结构">
              <el-input
                size="medium"
                v-model="form.lmjg"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="lmlx" label="路面类型">
              <!-- <el-input
                size="medium"
                v-model="form.lmlx"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>-->
              <el-select
                size="medium"
                v-model="form.lmlx"
                placeholder="请选择"
                style="width:100%"
                :disabled="lookOrEdit == 3"
              >
                <el-option
                  :label="item.keys"
                  :value="item.keys"
                  v-for="item in codeLmlx?codeLmlx:[]"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="gcdd_sj" label="工程地点 市级">
              <!-- <el-input
                size="medium"
                v-model="form.gcdd_sj"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>-->
              <el-select
                size="medium"
                v-model="form.gcdd_sj"
                placeholder="请选择"
                style="width:100%"
                :disabled="lookOrEdit == 3"
                @change="getDistrict();form.gcdd_qx = null;$refs.form.clearValidate('gcdd_sj')"
              >
                <el-option
                  :label="item.name"
                  :value="item.name"
                  v-for="item in cityList?cityList:[]"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="gcdd_qx" label="区县">
              <!-- <el-input
                size="medium"
                v-model="form.gcdd_qx"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>-->
              <el-select
                size="medium"
                v-model="form.gcdd_qx"
                placeholder="请选择"
                style="width:100%"
                :disabled="lookOrEdit == 3"
                @change="$forceUpdate()"
              >
                <el-option
                  :label="item.name"
                  :value="item.name"
                  v-for="item in District?District:[]"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="gcdd_xxdz" label="详细地址">
              <el-input
                size="medium"
                v-model.trim="form.gcdd_xxdz"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item prop="xmzh" label="项目指挥">
              <el-input
                size="medium"
                v-model.trim="form.xmzh"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="xmzh_lxfs" label="联系电话">
              <el-input
                size="medium"
                v-model.trim="form.xmzh_lxfs"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="xxfzr" label="信息负责人">
              <el-input
                size="medium"
                v-model="form.xxfzr"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="xxfzr_lxfs" label="联系电话">
              <el-input
                size="medium"
                v-model="form.xxfzr_lxfs"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
                @input="$forceUpdate();"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">行政等级</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item prop="xzdj">
              <el-radio-group
                v-model="form.xzdj"
                @change="$forceUpdate();radioChange()"
                :disabled="lookOrEdit == 3"
              >
                <el-radio label="国道">国道</el-radio>
                <el-radio label="省道">省道</el-radio>
                <el-radio label="农村公路（林下经济路）">农村公路（林下经济路）</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">建设规模</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="4" v-if="form.xzdj == '国道' || form.xzdj == '省道' || !form.xzdj">
            <el-form-item 
            prop="yijl" 
            label="一级路(km)" 
            :label-width="'100px'"
            :rules="[{ required: false,  message: '不能超过20位',trigger: 'blur' }]"
            >
              <el-input
                @input="luInputChange"
                size="medium"
                v-model="form.yijl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5" v-if="form.xzdj == '国道' || form.xzdj == '省道' || !form.xzdj">
            <el-form-item 
            prop="erjl" 
            label="二级路(km)" 
            :label-width="'100px'"
            :rules="[{ required: false,  message: '不能超过20位',trigger: 'blur' }]"
            >
            <!--  -->

              <el-input
                @input="luInputChange"
                size="medium"
                v-model="form.erjl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item 
            prop="sanjl" 
            label="三级路(km)" 
            :label-width="'100px'"
            :rules="[{ required: false,  message: '不能超过20位',trigger: 'blur' }]"
            >
              <el-input
                size="medium"
                @input="luInputChange"
                v-model="form.sanjl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item 
            prop="sijl" 
            label="四级路(km)" 
            :label-width="'100px'"
            :rules="[{ required: false,  message: '不能超过20位',trigger: 'blur' }]"
            >
              <el-input
                size="medium"
                @input="luInputChange"
                v-model="form.sijl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5" v-if="form.xzdj == '农村公路（林下经济路）'">
            <!-- <el-form-item 
            prop="wujl2" 
            label="五级路(km)" 
            :label-width="'100px'"
            
            >
              <el-input
                size="medium"
                v-model="form.wujl2"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
                @input="$forceUpdate();luInputChange()"
              ></el-input>
            </el-form-item> -->
          </el-col>
          <el-col :span="5">
            <el-form-item 
            prop="wujl" 
            label="总里程(km)" 
            :label-width="'100px'"
            :rules="[{ required: false,  message: '不能超过20位',trigger: 'blur' }]"
            >
              <!-- :rules="[{ required: true, message: '该值不能为空' }]" -->
              <el-input
                size="medium"
                v-model.trim="form.wujl"
                autocomplete="off"
                @input="$forceUpdate();$refs.form.clearValidate('wujl')"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">主要工程量</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item prop="lmjcgczl" label="路面基层工程总量(km)" >
              <el-input
                size="medium"
                v-model="form.lmjcgczl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="lmmcgczl" label="路面面层工程总量(km)" >
              <el-input
                size="medium"
                v-model="form.lmmcgczl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="ljtsfgczl" label="路基土石方工程总量(万m³)" >
              <el-input
                size="medium"
                v-model="form.ljtsfgczl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="fsgc" label="附属工程(万元)" >
              <el-input
                size="medium"
                v-model="form.fsgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item prop="fdgc" label="辅道工程(万元)" >
              <el-input
                size="medium"
                v-model="form.fdgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="qhhntgczl" label="桥涵混凝土工程总量(万m³)" >
              <el-input
                size="medium"
                v-model="form.qhhntgczl"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="jtgc" label="交通工程(万元)" >
              <el-input
                size="medium"
                v-model="form.jtgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item prop="fjgc" label="房建工程(万元)" >
              <el-input
                size="medium"
                v-model="form.fjgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="jdgc" label="机电工程(万元)" >
              <el-input
                size="medium"
                v-model="form.jdgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="lhgc" label="绿化工程(万元)" >
              <el-input
                size="medium"
                v-model="form.lhgc"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">项目投资</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item
              prop="gszes"
              label="估算总额(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.gszes"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
              <!-- type="number" -->
            </el-form-item>
          </el-col>
          <el-col :span="6"></el-col>
          <el-col :span="6"></el-col>
          <el-col :span="6"></el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item
              prop="gsze"
              label="概算总额(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.gsze"
                autocomplete="off"
                @input="$forceUpdate();"
                :disabled="lookOrEdit == 3"
                @blur="selBlur(form.gsze,'gsze')"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="zycgs"
              label="中央车购税(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.zycgs"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="sczzj"
              label="省财政资金(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.sczzj"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="ysze"
              label="地方建设资金(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.ysze"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item
              prop="ysze_n"
              label="预算总额(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.ysze_n"
                autocomplete="off"
                @input="$forceUpdate();$refs.form.clearValidate('ysze_n')"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="zbsx"
              label="招标上限(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.zbsx"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="zbj"
              label="中标价(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.zbj"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              prop="htj"
              label="合同价(万元）"
              
            >
              <el-input
                size="medium"
                v-model="form.htj"
                autocomplete="off"
                :disabled="lookOrEdit == 3"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="background: #f8fbff;">
          <el-col :span="24">
            <span class="d-start title">项目工期</span>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="jhkgrq" label="计划开工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.jhkgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
                :picker-options="pickerOptions1"
                @change="getStartTime"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="jhjgrq" label="计划交工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.jhjgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
                :picker-options="pickerOptions2"
                @change="getEndTime"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="wgrq" label="完工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.wgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="sjkgrq" label="实际开工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.sjkgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sjjgrq" label="实际交工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.sjjgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
              ></el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="jgrq" label="竣工日期">
              <el-date-picker
                value-format="yyyy-MM-dd"
                size="medium"
                v-model="form.jgrq"
                type="date"
                placeholder="选择日期"
                style="width:100%"
                :disabled="lookOrEdit == 3"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- <el-form-item prop="name" label="活动区域" >
        <el-select size="medium" v-model="form.region" placeholder="请选择活动区域">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
        </el-form-item>-->
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button size="medium" @click="dialogFormVisible=false">取 消</el-button>
      <el-button
        size="medium"
        type="primary"
        @click="save"
        v-if="lookOrEdit != 3"
        :loading="loading"
      >保 存</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: [
    "dialogFormVisible1",
    "item",
    "resdata",
    "lookOrEdit",
    "dataStructure",
    "codeLmlx",
    "cityList",
  ],
  data() {
    return {
      // form: {},
      formLabelWidth: "150px",
      dialogFormVisible: false,
      loading: false,
      defaultProps: {
        children: "children",
        label: "name",
      },
      rules: {
        gcgk: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        xmmc: [
          {
            required: true,
            max: 200,
            message: "该值不能为空且不能超过200个字",
            trigger: "blur",
          },
        ],
        xmbh: [
          {
            required: true,
            message: "该值不能为空",
            trigger: "blur",
          },
        ],
        // xmzt: [{ required: true, message: "该值不能为空", trigger: "change" }],
        // jszt: [{ required: true, message: "该值不能为空", trigger: "change" }],
        wujl: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        jhkgrq: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        jhjgrq: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        gcdd_sj: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        gcdd_xxdz: [
          { required: true, message: "该值不能为空", trigger: "blur" },
        ],
        xmzh: [{ required: true, message: "该值不能为空", trigger: "blur" }],
        xmzh_lxfs: [
          {
            required: true,
            trigger: "blur",
            message: "该值不能为空",
          },
        ],
      },
      form: {},
      mineStatus: {},
      mineStatusValue: "",
      saveHide: false,
      District: [],
      pickerOptions1: {
        disabledDate() {},
      },
      pickerOptions2: {
        disabledDate() {},
      },
    };
  },
  methods: {
    //wxs 8-4
    luInputChange() {
      var count =
        Number(this.form.yijl ? this.form.yijl : null) +
        Number(this.form.erjl ? this.form.erjl : null) +
        Number(this.form.sanjl ? this.form.sanjl : null) +
        Number(this.form.sijl ? this.form.sijl : null) +
        Number(this.form.wujl2 ? this.form.wujl2 : null);
        console.log(count);
        
        this.form.wujl = count.toString();
        this.$forceUpdate();
    },
    radioChange() {
      this.form.yijl = null;
      this.form.erjl = null;
      this.form.sanjl = null;
      this.form.sijl = null;
      this.form.wujl2 = null;
      this.form.wujl = null;
    },
    getStartTime(time) {
      if (!time) {
        this.pickerOptions2.disabledDate = null;
        // console.log(2);
        return;
      }
      let timer = new Date(time);
      this.pickerOptions2.disabledDate = function (time) {
        return timer.getTime() >= time.getTime() - 8.64e6;
      };
    },
    getEndTime(time) {
      if (!time) {
        this.pickerOptions1.disabledDate = null;
        // console.log(2);
        return;
      }
      let timer = new Date(time);
      this.pickerOptions1.disabledDate = function (time) {
        // console.log(1)
        return timer.getTime() <= time.getTime() - 8.64e6;
      };
    },
    selBlur(data, item) {
      //判断金额小不小于10位数小于就清除校验
      if (data && data.length <= 10) {
        this.$refs.form.clearValidate(item);
      }
    },
    // handleNodeExpand(val, b, c) {
    //   console.log(c.$refs.node.offsetTop);
    // },
    // handleNodeClick(val) {
    //   // let scroll = (document.querySelector(
    //   //   ".el-scrollbar__bar.is-vertical"
    //   // ).scrollTop = 0);
    //   // console.log(val);
    //   this.mineStatusValue = val.id.toString();
    //   this.form.jszt = val.id.toString();
    //   this.mineStatus = val.name;
    //   this.$refs.form.clearValidate("jszt");
    //   this.$refs.sel.blur();
    // },
    // handleNodeFocus() {
    //   let node = this.$refs.vueTree.getCheckedNodes();
    //   let key = this.$refs.vueTree.getCheckedKeys();
    //   console.log(key);
    //   console.log(node);
    // },
    close() {
      this.$emit("close", this.saveHide);
    },
    save() {
      this.$refs.form.validate((valid) => {
        this.$forceUpdate();
        if (valid) {
          this.loading = true;
          this.$post("/api/Project/actions", this.form).then((res) => {
            if (res.code == 200) {
              this.$message({
                message: res.msg,
                type: "success",
              });
              this.saveHide = true; // 判断是否是保存
              this.dialogFormVisible = false;
            } else {
              this.$message({
                message: res.msg,
                type: "error",
              });
            }
            this.loading = false;
          });
        } else {
          return false;
        }
      });
    },
    getDistrict() {
      this.cityList.forEach((v) => {
        if (v.name == this.form.gcdd_sj) {
          //编辑或查看时获取县的数据
          this.$get("api/project/getDistrict", { code: v.adcode }).then(
            (res) => {
              if (res.code == 200 && res.data) {
                this.District = res.data;
              }
            }
          );
        }
      });
    },
  },
  mounted() {},
  created() {},
  watch: {
    dialogFormVisible1(news) {
      this.dialogFormVisible = news;
      if (news) {
        this.saveHide = false;
        this.form = { ...this.item };
        console.log(this.form);
        // this.form.wujl = this.wuji ? this.wuji : 0;
        // this.form.gsze = this.gsze ? this.gsze : 0;
        // this.form.ysze_n = this.ysze_n ? this.ysze_n : 0;
        if (this.lookOrEdit !== 1) {
          this.getDistrict();
          this.resdata.organize.forEach((v) => {
            if (v.id == this.form.jszt) {
              this.mineStatus = v.name;
              this.mineStatusValue = v.id;
            }
          });
          // 进行时间制约判断
          this.getStartTime(this.form.jhkgrq ? this.form.jhkgrq : null);
          this.getEndTime(this.form.jhjgrq ? this.form.jhjgrq : null);
        } else {
          this.mineStatus = null;
          this.mineStatusValue = null;
          this.getStartTime(this.form.jhkgrq ? this.form.jhkgrq : null);
          this.getEndTime(this.form.jhjgrq ? this.form.jhjgrq : null);
        }
        this.form.xzdj = this.form.xzdj ? this.form.xzdj : "国道";
        let fomate_protype = [
          "yijl",
          "erjl",
          "sanjl",
          "sijl",
          "wujl2",
          "wujl",
          "gsze",
          "zycgs",
          "sczzj",
          "ysze",
          "zbsx",
          "zbj",
          "htj",
          "ysze_n",
          "gszes",
          "ljkd",
          "lmdk",
          "lmjcgczl",
          "lmmcgczl",
          "ljtsfgczl",
          "fsgc",
          "fdgc",
          "qhhntgczl",
          "jtgc",
          "fjgc",
          "jdgc",
          "lhgc",
        ];
        fomate_protype.forEach((v) => {
          this.form[v] == 0 ? (this.form[v] = null) : null;
        });
        // console.log(this.form.wujl2)
      }
    },

    // wuji(news) {
    //   this.form.wujl = news ? news : null;
    //   news ? this.$refs.form.clearValidate("wujl") : null;
    // },
    gsze(news) {
      this.form.gsze = news ? news.toFixed(4).toString() : "0";
      this.$refs.form ? this.$refs.form.clearValidate("gsze") : null;
    },
    ysze_n(news) {
      this.form.ysze_n = news ? news.toFixed(4).toString() : "0";
      this.$refs.form ? this.$refs.form.clearValidate("ysze_n") : null;
    },
  },
  computed: {
    // wuji() {
    //   return (
    //     Number(this.form.yijl ? this.form.yijl : null) +
    //     Number(this.form.erjl ? this.form.erjl : null) +
    //     Number(this.form.sanjl ? this.form.sanjl : null) +
    //     Number(this.form.sijl ? this.form.sijl : null) +
    //     Number(this.form.wujl2 ? this.form.wujl2 : null)
    //   );
    // },
    gsze() {
      return (
        Number(this.form.zycgs ? this.form.zycgs : null) +
        Number(this.form.sczzj ? this.form.sczzj : null) +
        Number(this.form.ysze ? this.form.ysze : null)
      );
    },
    ysze_n() {
      return (
        Number(this.form.zbsx ? this.form.zbsx : null) +
        Number(this.form.zbj ? this.form.zbj : null) +
        Number(this.form.htj ? this.form.htj : null)
      );
    },
  },
};
</script>
<style lang="less">
.m-table {
  width: 100%;
  .cell {
    height: 50px;
    line-height: 50px;
    color: #909399;
    font-family: "Microsoft YaHei";
    outline: none;
    font-size: 14px;
    border-top: 1px solid rgba(232, 237, 238, 1);
    text-align: left;
  }
  th:first-child .cell {
    padding-left: 37px;
  }
  th:last-child .cell {
    text-align: right;
    margin-right: 10px;
  }
}
.el-tree {
  border-top: 1px solid rgba(232, 237, 238, 1);
  height: 100%;
  overflow-y: scroll;
}
.el-tree-node__content {
  height: 50px;
  border-bottom: 1px solid rgba(232, 237, 238, 1);
}

.el-tree-node__content > .el-tree-node__expand-icon {
  border: 1px #ddd solid;
  border-radius: 50%;
  margin-left: 5px;
  margin-right: 10px;
  padding: 4px;
}
.el-tree-node__expand-icon.is-leaf {
  border: 0;
}
.el-select-dropdown__list {
  padding: 0;
}
.trees {
  overflow-y: hidden;
  .el-tree--highlight-current
    .el-tree-node.is-current
    > .el-tree-node__content {
    background: none;
  }
  .el-tree-node__content > .el-tree-node__expand-icon {
    border: 0;
  }
  .el-tree-node__content {
    height: 40px;
    border-bottom: 1px solid #eef4f5;
  }
  height: auto;
  padding: 0;
  .el-tree-node__label {
    color: #606266;
    font-weight: normal;
  }
}
</style>
<style scoped lang="less">
.title {
  width: 120px;
  padding: 10px 12px;
  background: #f8fbff;
  font-size: 18px;
  font-family: Microsoft YaHei UI, Microsoft YaHei UI-Bold;
  font-weight: 700;
  text-align: left;
  color: #409eff;
}
</style>